﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Credisoft.Models.Credisoft_BO;

namespace Credisoft.Models.Credisoft_Model.Credisoft_DAO
{
    public class AnalysisDAO
    {
        public AnalysisBO getAnalysisFromEnterprise(int idEnterprise)
        {
            AnalysisBO objAnalysis = new AnalysisBO();
            using (credisoftEntities bd = new credisoftEntities())
            {
                analisis found = (from p in bd.analisis
                                  where p.idempresa == idEnterprise
                                  select p).First();
                if (found != null)
                {
                    objAnalysis.analysisId = found.idempresa;
                    objAnalysis.assigmentDate = (DateTime)found.fechaasignacion;
                    objAnalysis.creditLimit = (double)found.limitecredito;
                    objAnalysis.currencyId = found.idmoneda;
                    objAnalysis.endDate = (DateTime)found.fechafin;
                    objAnalysis.enterpriseId = found.idempresa;
                    objAnalysis.interest = found.interes;
                    objAnalysis.recordDate = (DateTime)found.fecharegistro;
                    objAnalysis.startDate = (DateTime)found.fechainicio;
                    objAnalysis.status = found.estado;
                    objAnalysis.typeOperationId = found.idtipooperacion;
                    objAnalysis.userId = found.idusuario;
                }
            }

            return objAnalysis;
        }
    }
}